Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/mulithreading-changes #168

Merged
merged 11 commits into from
Mar 3, 2024
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,7 @@ multithreaded mode. In order to utilize this mode, julia must have more than 1 t
julia --threads 4
```

``serveparallel(queuesize=1024)`` Starts the webserver in streaming mode and spawns n - 1 worker
threads. The ``queuesize`` parameter sets how many requests can be scheduled within the queue (a julia Channel)
before they start getting dropped. Each worker thread pops requests off the queue and handles them asynchronously within each thread.
``serveparallel()`` Starts the webserver in streaming mode and handles requests in a cooperative multitasking approach. This function uses `Threads.@spawn` to schedule a new task on any available thread. Meanwhile, @async is used inside this task when calling each request handler. This allows the task to yield during I/O operations.

```julia
using Oxygen
Expand Down
6 changes: 2 additions & 4 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ end

app2 = instance()

app1.get("/") do
app2.get("/") do
text("server B")
end

Expand All @@ -512,9 +512,7 @@ multithreaded mode. In order to utilize this mode, julia must have more than 1 t
julia --threads 4
```

``serveparallel(queuesize=1024)`` Starts the webserver in streaming mode and spawns n - 1 worker
threads. The ``queuesize`` parameter sets how many requests can be scheduled within the queue (a julia Channel)
before they start getting dropped. Each worker thread pops requests off the queue and handles them asynchronously within each thread.
``serveparallel()`` Starts the webserver in streaming mode and handles requests in a cooperative multitasking approach. This function uses `Threads.@spawn` to schedule a new task on any available thread. Meanwhile, @async is used inside this task when calling each request handler. This allows the task to yield during I/O operations.

```julia
using Oxygen
Expand Down
3 changes: 2 additions & 1 deletion src/context.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module AppContext
import Base: @kwdef, wait, close, isopen
import Base.Threads: ReentrantLock
using HTTP
using HTTP: Server, Router
using ..Types
Expand Down Expand Up @@ -43,7 +44,7 @@ end
router :: Router = Router()
custommiddleware :: Dict{String, Tuple} = Dict{String, Tuple}()
history :: History = History(1_000_000)
parallel_handler :: Ref{Nullable{Handler}} = Ref{Nullable{Handler}}(nothing)
history_lock :: ReentrantLock = ReentrantLock()
end

@kwdef struct Context
Expand Down
Loading
Loading