Skip to content

Instantly share code, notes, and snippets.

View siddharth1001's full-sized avatar
Appreciates honest efforts

Siddharth siddharth1001

Appreciates honest efforts
  • India
View GitHub Profile
@siddharth1001
siddharth1001 / good_coroutine_usage2.kt
Created May 25, 2023 08:52
How to write coroutines efficiently - 2
suspend fun performBlockingOperationSuspended(jobName: String) {
// non-blocking delay - delay() is a suspending function un-like Thread.sleep()
delay(1000)
println("Blocking operation completed. jobName = $jobName, thread : ${Thread.currentThread().name}")
}
fun main() = runBlocking {
val executionTime = measureTimeMillis {
val job1 = launch {
@siddharth1001
siddharth1001 / good_coroutine_usage.kt
Last active May 25, 2023 08:45
How to write coroutines efficiently - 1
import kotlinx.coroutines.*
import kotlin.system.measureTimeMillis
fun performBlockingOperation(jobName: String) {
// Simulating a blocking operation
Thread.sleep(1000)
println("Blocking operation completed. jobName = $jobName, thread : ${Thread.currentThread().name}")
}
@siddharth1001
siddharth1001 / bad_coroutine_usage.kt
Last active May 25, 2023 07:09
How not to write coroutines
import kotlinx.coroutines.*
import kotlin.system.measureTimeMillis
fun performBlockingOperation(jobName: String) {
// Simulating a blocking operation
Thread.sleep(1000)
println("Blocking operation completed. jobName = $jobName, thread : ${Thread.currentThread().name}")
}
@siddharth1001
siddharth1001 / kotlin_coroutines_concurrent_tasks_example1.kt
Last active May 25, 2023 06:20
Writing a simple coroutine which performs concurrent execution
import kotlinx.coroutines.*
import kotlin.system.measureTimeMillis
fun main() {
runBlocking {
val executionTime = measureTimeMillis {
val job1 = launch { // Coroutine 1
delay(1000)
println("Coroutine 1 completed")
}
@siddharth1001
siddharth1001 / solr-leader-deployment.yml
Created June 19, 2022 07:10
Solr Deployment and service - k8s
# solr-leader deployment
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/component: solr-leader
app.kubernetes.io/name: solr-leader
app.kubernetes.io/part-of: solr-deployment
name: solr-leader
namespace: dev
@siddharth1001
siddharth1001 / solr-k8s-follower.yml
Last active June 19, 2022 07:14
Solr Deployment and service - k8s - follower
# solr-follower deployment
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/component: solr-follower
app.kubernetes.io/name: solr-follower
app.kubernetes.io/part-of: solr-deployment
name: solr-follower
namespace: dev
@siddharth1001
siddharth1001 / MySql_README.md
Created November 13, 2017 05:10 — forked from hofmannsven/README.md
My simply MySQL Command Line Cheatsheet